package com.atguigu.controller;

import com.atguigu.pojo.Delivery;
import com.atguigu.service.DeliveryService;
import com.atguigu.service.impl.DeliveryServiceImpl;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

@WebServlet("/delivery/Update")
public class UserDeliveryUpdateController extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id = req.getParameter("id");//快递的id
        //可以根据这个快递的id查询出这个快递的信息
        DeliveryService deliveryService = new DeliveryServiceImpl();
        Delivery delivery = deliveryService.getDeliveryById(Integer.valueOf(id));
        //将用户点击编辑的已有快递信息动态渲染到对应的输入框中，通过request域传到edit.jsp中
        req.setAttribute("delivery",delivery);
        req.getRequestDispatcher("/edit.jsp").forward(req,resp);
    }
}
